# For each of these string methods, run the code and work out what they do!
# add a comment using # to each one to explain what it does

user_string = input("Enter a string: ")

print(f"\nOriginal String: {user_string}")

#Converts all uppercase letters in the string to lowercase; non-alphabetic characters remain unchanged
print(f"Modified String 1: {user_string.lower()}")

#Converts all lowercase letters in the string to uppercase; non-alphabetic characters remain unchanged
print(f"Modified String 2: {user_string.upper()}")

#Removes whitespace characters (spaces, newlines \n, tabs \t, etc.) from the start and end of the string by default. 
#If a specific character is passed as an argument (e.g., strip('x')), it removes that character from the start and end instead.
print(f"Modified String 3: {user_string.strip()}")

#replace('a', '@'): Replaces all occurrences of the specified old substring (first argument, 'a' here) 
#with the new substring (second argument, '@' here). Returns a new string; the original string remains unmodified.
print(f"Modified String 4: {user_string.replace('a', '@')}")

#Converts the first character of the string to uppercase and all other characters to lowercase. 
#If the string starts with a non-alphabetic character, only subsequent letters are converted to lowercase.
print(f"Modified String 5: {user_string.capitalize()}")

#A string slicing syntax where step = -1. It traverses the string from the last character to the first, 
#effectively reversing the string. This is a general Python sequence operation (not a string method).
print(f"Modified String 6: {user_string[::-1]}")

#Converts the first character of each "word" in the string to uppercase and all other characters to lowercase. 
#Words are typically separated by whitespace characters (spaces, tabs, etc.).
print(f"Modified String 7: {user_string.title()}")

#A built-in Python function (not a string method) that returns the length of the string, 
#i.e., the number of characters (including spaces and symbols).
print(f"Modified String 8: {len(user_string)}")

#Searches for the first occurrence of the specified substring (argument 'a' here) in the string. 
#Returns the starting index of the substring if found; returns -1 if the substring is not present (case-sensitive).
print(f"Modified String 9: {user_string.find('a')}")

#Counts the total number of occurrences of the specified substring (argument 'a' here) in the string. 
#Returns 0 if the substring is not found (case-sensitive).
print(f"Modified String 10: {user_string.count('a')}")

#Checks if the string begins with the specified prefix (argument 'Hello' here). 
#Returns a boolean value: True if it matches, False otherwise (case-sensitive).
print(f"Modified String 11: {user_string.startswith('Hello')}")

#Checks if the string ends with the specified suffix (argument '!' here). 
#Returns a boolean value: True if it matches, False otherwise (case-sensitive).
print(f"Modified String 12: {user_string.endswith('!')}")

#Checks if all characters in the string are either alphabetic (a-z/A-Z) or numeric (0-9). 
#Returns False for empty strings or strings containing non-alphanumeric characters (e.g., spaces, symbols).
print(f"Modified String 13: {user_string.isalnum()}")

#Checks if all characters in the string are alphabetic (a-z/A-Z). 
#Returns False for empty strings or strings containing numbers, symbols, or spaces.
print(f"Modified String 14: {user_string.isalpha()}")

#Checks if all characters in the string are numeric digits (0-9). 
#Returns False for empty strings, or strings containing letters, symbols, spaces, or non-ASCII digits (e.g., Chinese numerals "一", decimals "1.2").
print(f"Modified String 15: {user_string.isdigit()}")



######
# if you finish, you can look at some more: https://www.w3schools.com/python/python_ref_string.asp
# and add some extras to this selection!
# You can also combine these functions - have a play around and see what you can do!